package com.czxy.controller;

import com.czxy.pojo.Brand;
import com.czxy.pojo.group.BaseResult;
import com.czxy.service.BrandService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Liuyunqin 17674029449@163.com
 * @date 2018/12/20 16:10
 */
@RestController
@RequestMapping
public class BrandController {

    @Autowired
    private BrandService brandService;


    /**
     * 根据三级分类的id查询品牌
     * @param catId
     * @return
     */
    @GetMapping("brands/{catid}")
    public ResponseEntity<Object> findBrandByCatId(@PathVariable("catid") Integer catId){
        List<Brand> allBrandByCid = this.brandService.findBrandByCatId(catId);
        BaseResult br = new BaseResult(0,"成功",allBrandByCid);
        return ResponseEntity.ok(br);
    }

}
